﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IQueue.cs" company="AzureContrib (Open source library http://azurecontrib.codeplex.com)">
//   Microsoft Public License (Ms-PL)
// </copyright>
// <summary>
//   Exception for errors when handling Windows Azure Cloud Drives.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

using System;
using System.Diagnostics.CodeAnalysis;

using Microsoft.WindowsAzure.StorageClient;

namespace AzureContrib.WindowsAzure.StorageClient
{
	/// <summary>
	/// Abstraction over a <see cref="CloudQueue"/>
	/// </summary>
	/// <typeparam name="T">The type of messages to queue.</typeparam>
	[SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix", Justification = "This interface is a generic queue. The naming is correct.")]
	public interface IQueue<T>
	{
		/// <summary>
		/// <see cref="CloudQueue.AddMessage(CloudQueueMessage)"/> but we add a <see cref="CloudQueueMessage{T}"/> with a nice paylod <typeparamref name="T"/>.
		/// </summary>
		/// <param name="queueMessage">The message to enqueue</param>
		void AddMessage(CloudQueueMessage<T> queueMessage);

		/// <summary>
		/// <see cref="CloudQueue.GetMessage()"/> as a <see cref="CloudQueueMessage{T}"/>
		/// </summary>
		/// <param name="visibilityTimeout">The dequeue time</param>
		/// <returns>The dequeued <see cref="CloudQueueMessage{T}"/>.</returns>
		CloudQueueMessage<T> GetMessage(TimeSpan visibilityTimeout);

		/// <summary>
		/// Delete a message from the queue.
		/// </summary>
		/// <param name="toDelete">The message to delete.</param>
		void DeleteMessage(CloudQueueMessage<T> toDelete);

		/// <summary>
		/// Calls <see cref="CloudQueue.PeekMessage"/>.
		/// </summary>
		/// <returns>True if there is a message in the queue.</returns>
		bool HasMessage();
	}
}